package com.woniu.util.utils;

import lombok.Data;

@Data
public class HttpResult<T> {

    private Integer code;
    private String msg;
    private T data;

    public HttpResult<T> ok(T t) {
        return new HttpResult(ResultEnum.LOGIN_SUCCESS.getCode(),t);
    }
    public HttpResult<T> ok(){
        return new HttpResult(ResultEnum.LOGIN_SUCCESS.getCode(),"OK");
    }
    public HttpResult<T> fail(){
        return new HttpResult(ResultEnum.LOGIN_FAIL.getCode(),"FAIL");
    }
    public static final HttpResult<Void> LOGIN_SUCCESS=
            new HttpResult(ResultEnum.LOGIN_SUCCESS.getCode(), ResultEnum.LOGIN_SUCCESS.getMsg());
    public static final HttpResult<Void> LOGIN_FAIL=
            new HttpResult(ResultEnum.LOGIN_FAIL.getCode(), ResultEnum.LOGIN_FAIL.getMsg());
    public static final HttpResult<Void> NO_LOGIN=
            new HttpResult(ResultEnum.NO_LOGIN.getCode(), ResultEnum.NO_LOGIN.getMsg());
    public static final HttpResult<Void> NO_AUTH=
            new HttpResult(ResultEnum.NO_AUTH.getCode(), ResultEnum.NO_AUTH.getMsg());

    public HttpResult(){

    }

    public HttpResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public HttpResult(Integer code, T data) {
        this.code = code;
        this.data = data;
    }
}
